/*=====================================================
Critical Links
Auto Configuration Server

Authors:
	Rui Eduardo Gouveia Gil - r-gil@critical-links.com

Date: 2010
Version 0.1
=======================================================*/
#ifndef __HTTPFILEUPLOAD_H__
#define __HTTPFILEUPLOAD_H__

#include <map>
#include <fstream>
#include <iostream>
#include <tinyxml.h>
#include <rgcpp/tools/ToHex.h>
#include <boost/filesystem.hpp>
#include <rgcpp/structs/Types.h>
#include <rgcpp/utils/ZipFile.h>
#include <rgcpp/tools/ToString.h>
#include <pion/net/WebService.hpp>
#include <rgcpp/structs/Sequence.h>
#include <rgcpp/structs/FileLock.h>
#include <rgcpp/tools/SHAGenerator.h>
#include <rgcpp/exceptions/RuntimeException.h>

namespace acs
{

class HttpFileUpload : public pion::net::WebService
{
	private:
		static std::string TMP_FILE_PEFIX;
		static rgcpp::Sequence<int> fileID;

	public:
		HttpFileUpload();
		~HttpFileUpload();
		virtual void operator()(pion::net::HTTPRequestPtr& request, pion::net::TCPConnectionPtr& tcp_conn);

	private:
		void parseContent(std::string& file, std::string& tempFile);
		rgcpp::Types<std::string,std::string,std::string> getParameter(std::ifstream& stream, std::string delemiter);

		std::string generateBackupSHA(const std::string& filePath, const std::string& restoreOptions);

		rgcpp::Types<std::string,std::string,std::string,std::string,std::string,std::string,std::string> getBackupInformation(std::string filePath);
};

}

#endif

